package com.lixin.smartclassroom.ui.home.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.lixin.smartclassroom.R;
import com.lixin.smartclassroom.bean.DataListBean;
import com.youth.banner.adapter.BannerAdapter;

import java.util.List;

/**
 * Description
 * Author: lwc
 * Date:2023/12/5 16:55
 */
public class ExcitingImageBannerAdapter extends BannerAdapter<String, ExcitingImageBannerAdapter.BannerViewHolder> {

    private Context context;
    private List<String> list;
    private LayoutInflater inflater;

    public ExcitingImageBannerAdapter(Context context, List<String> mDatas) {
        //设置数据，也可以调用banner提供的方法,或者自己在adapter中实现
        super(mDatas);
        this.context = context;
        this.list = mDatas;
        inflater = LayoutInflater.from(context);
    }

    //创建ViewHolder，可以用viewType这个字段来区分不同的ViewHolder
    @Override
    public BannerViewHolder onCreateHolder(ViewGroup parent, int viewType) {
        View view = inflater.inflate(R.layout.item_img_banner, parent, false);


        view.setLayoutParams(new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
        BannerViewHolder viewHolder = new BannerViewHolder((ViewGroup) view);

        return viewHolder;
    }

    @Override
    public void onBindView(BannerViewHolder holder, String data, int position, int size) {
        TextView tv = holder.itemView.findViewById(R.id.tv);
        ImageView img = holder.itemView.findViewById(R.id.img);
        Glide.with(context).load(list.get(position)).into(img);
        tv.setText((position + 1) + "/" + size);

    }

    class BannerViewHolder extends RecyclerView.ViewHolder {

        public BannerViewHolder(@NonNull View itemView) {
            super(itemView);
        }
    }
}